# -*- coding: utf-8 -*-
# @Time    : 2020/3/15 下午5:58
# @Author  : lilong

from abc import ABCMeta, abstractmethod


# =============================
# 代码框架 Version 1.0
# ==============================

# 交通类单独剥离出来
class IVehicle(metaclass=ABCMeta):
    """交通工具的抽象类"""

    @abstractmethod
    def running(self):
        pass


class SharedBicycle(IVehicle):
    """共享单车"""

    def running(self):
        print("骑共享单车(轻快便捷)", end='')


class ExpressBus(IVehicle):
    """快速公交"""

    def running(self):
        print("坐快速公交(经济绿色)", end='')


class Express(IVehicle):
    """快车"""

    def running(self):
        print("打快车(快速方便)", end='')


class Subway(IVehicle):
    """地铁"""

    def running(self):
        print("坐地铁(高效安全)", end='')


# 具体的对象，可配置不同的IVehicle实例作为属性
class Classmate:
    """参加聚餐的同学"""

    def __init__(self, name, vechicle):
        self.__name = name
        self.__vechicle = vechicle

    def attendTheDinner(self):
        print(self.__name + " ", end='')
        self.__vechicle.running()
        print(" 来参加聚餐！")


def testTheDinner():

    sharedBicycle = SharedBicycle()
    joe = Classmate("Joe", sharedBicycle)
    joe.attendTheDinner()

    helen = Classmate("Helen", Subway())
    helen.attendTheDinner()
    henry = Classmate("Henry", ExpressBus())

    henry.attendTheDinner()
    ruby = Classmate("Ruby", Express())
    ruby.attendTheDinner()


testTheDinner()
